package nl.scalasim

import nl.scalasim.actors.traits.SimulationActor

/**
 * Some utility methods to improve readability of specifications. 
 *
 * @author Yigal Duppen
 * @since Nov 15, 2010
 */
object ActorUtils {

  /**
   * Retrieves the actor state from the specified simulation actor;
   * automatically fails is the simulation actor does not respond
   * within <code>timeout</code> milliseconds.
   *
   * This method blocks the current thread until the state has been
   * retrieved. 
   */
  def state(s: SimulationActor, timeout: Int = 100): ActorState = {
    (s !? (timeout, GetState)).get.asInstanceOf[ActorState]
  }


}